Test Series - Data Structure

Test Number 4/115

Q: Process of inserting an element in stack is called ____________
A. Create
B. Push
C. Evaluation
D. Pop
Solution: Push operation allows users to insert elements in the stack. If the stack is filled completely and trying to perform push operation stack – overflow can happen.
Q: Process of removing an element from stack is called __________
A. Create
B. Push
C. Evaluation
D. Pop
Solution: Elements in the stack are removed using pop operation. Pop operation removes the top most element in the stack i.e. last entered element.
Q:  In a stack, if a user tries to remove an element from an empty stack it is called _________
A. Underflow
B. Empty collection
C. Overflow
D. Garbage Collection
Solution: Underflow occurs when the user performs a pop operation on an empty stack. Overflow occurs when the stack is full and the user performs a push operation. Garbage Collection is used to recover the memory occupied by objects that are no longer used.
Q: Pushing an element into stack already having five elements and stack size of 5, then stack becomes ___________
A. Overflow
B. Crash
C. Underflow
D. User flow
Solution: The stack is filled with 5 elements and pushing one more element causes a stack overflow. This results in overwriting memory, code and loss of unsaved work on the computer.
Q: Entries in a stack are “ordered”. What is the meaning of this statement?
A. A collection of stacks is sortable
B. Stack entries may be compared with the ‘<‘ operation
C. The entries are stored in a linked list
D. There is a Sequential entry that is one by one
Solution: In stack data structure, elements are added one by one using push operation. Stack follows LIFO Principle i.e. Last In First Out(LIFO).
Q: Which of the following is not the application of stack?
A. A parentheses balancing program
B. Tracking of local variables at run time
C. Compiler Syntax Analyzer
D. Data Transfer between two asynchronous process
Solution: Data transfer between the two asynchronous process uses the queue data structure for synchronisation. The rest are all stack applications.
Q: Consider the usual algorithm for determining whether a sequence of parentheses is balanced. The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(()))?
A. 1
B. 2
C. 3
D. 4 or more
Solution: In the entire parenthesis balancing method when the incoming token is a left parenthesis it is pushed into stack. A right parenthesis makes pop operation to delete the elements in stack till we get left parenthesis as top most element. 3 elements are there in stack before right parentheses comes. Therefore, maximum number of elements in stack at run time is 3.
Q: Consider the usual algorithm for determining whether a sequence of parentheses is balanced. Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order). The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?
A. 1
B. 2
C. 3
D. 4 or more
Solution: In the entire parenthesis balancing method when the incoming token is a left parenthesis it is pushed into stack. A right parenthesis makes pop operation to delete the elements in stack till we get left parenthesis as top most element. 2 left parenthesis are pushed whereas one right parenthesis removes one of left parenthesis. 2 elements are there before right parenthesis which is the maximum number of elements in stack at run time.
Q: What is the value of the postfix expression 6 3 2 4 + – *?
A. 1
B. 40
C. 74
D. -18
Solution: Postfix Expression is (6*(3-(2+4))) which results -18 as output.
Q: Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?
A. 1
B. 2
C. 3
D. 4
Solution: When we perform the conversion from infix to postfix expression +, *, (, * symbols are placed inside the stack. A maximum of 4 symbols are identified during the entire conversion.

You Have Score    /10